# -*- coding: utf-8 -*-
## 定时任务系统

from apscheduler.scheduler import Scheduler
from saltstack.cron_jobs import healthCheck
from saltstack.cron_jobs import traverseKey
from saltstack.cron_jobs import procDetect

sched = Scheduler()
sched.add_interval_job(traverseKey, seconds = 30)
sched.add_interval_job(healthCheck, seconds = 30)
sched.add_interval_job(procDetect, seconds = 300)

sched.start()

## 下面这句加在定时任务模块的末尾...判断是否运行在uwsgi模式下, 然后阻塞mule主线程.
try:
    import uwsgi
    while True:
        sig = uwsgi.signal_wait()
        print(sig)
except Exception as err:
    pass
